//
//  PZPopUpController.h
//  PeiZiWangBei
//
//  Created by LK-IOS on 2017/11/1.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN


// 弹框背景模式
typedef NS_ENUM(NSUInteger, PZPopupMaskType) {
    PZPopupMaskTypeBlackBlur = 0,//黑色磨砂背景
    PZPopupMaskTypeWhiteBlur,//白色磨砂背景
    PZPopupMaskTypeWhite,//白色
    PZPopupMaskTypeClear,//透明色
    PZPopupMaskTypeBlackTranslucent // default，系统默认灰色
};

// 提示框显示的时候的位置
typedef NS_ENUM(NSUInteger, PZPopupLayoutType) {
    PZPopupLayoutTypeTop = 0,//从顶部出现
    PZPopupLayoutTypeBottom,//从底部出现
    PZPopupLayoutTypeLeft,//从左边出现
    PZPopupLayoutTypeRight,//从右边出现
    PZPopupLayoutTypeCenter // 从中间出现，默认
};

// 提示框消失的位置模式
typedef NS_ENUM(NSInteger, PZPopupSlideStyle) {
    PZPopupSlideStyleFromTop = 0,//顶部消失
    PZPopupSlideStyleFromBottom,//底部消失
    PZPopupSlideStyleFromLeft,//左边消失
    PZPopupSlideStyleFromRight,//右边消失
    PZPopupSlideStyleShrinkInOut,//
    PZPopupSlideStyleFade // 系统默认的消失方式
};

@protocol PZPopupControllerDelegate;

@interface PZPopUpController : NSObject

@property (nonatomic, weak) id <PZPopupControllerDelegate> _Nullable delegate;


/**
 返回
通过这种方式创建的提示框，背景是系统默认的弹框背景
 @param maskType 提示狂魔是
 @return 提示框
 */
+ (instancetype)popupControllerWithMaskType:(PZPopupMaskType)maskType;

/// The `popupView` is the parent view of your custom contentView
@property (nonatomic, strong, readonly) UIView *popupView;

/// Whether contentView is presenting.
@property (nonatomic, assign, readonly) BOOL isPresenting;

/// Set popup view display position. default is PZPopupLayoutTypeCenter
@property (nonatomic, assign) PZPopupLayoutType layoutType;

/// Set popup view slide Style. default is PZPopupSlideStyleFade
@property (nonatomic, assign) PZPopupSlideStyle slideStyle; // When `layoutType = PZPopupLayoutTypeCenter` is vaild.

/// set mask view of transparency, default is 0.5
@property (nonatomic, assign) CGFloat maskAlpha; // When set maskType is PZPopupMaskTypeBlackTranslucent vaild.

/// default is YES. if NO, Mask view will not respond to events.
@property (nonatomic, assign) BOOL dismissOnMaskTouched;

/// default is NO. if YES, Popup view disappear from the opposite direction.
@property (nonatomic, assign) BOOL dismissOppositeDirection; // When `layoutType = PZPopupLayoutTypeCenter` is vaild.

/// Content view whether to allow drag, default is NO
@property (nonatomic, assign) BOOL allowPan; // 1.The view will support dragging when popup view of position is at the center of the screen or at the edge of the screen. 2.The pan gesture will be invalid when the keyboard appears.

/// You can adjust the spacing relative to the keyboard when the keyboard appears. default is 0
@property (nonatomic, assign) CGFloat offsetSpacingOfKeyboard;

/// Use drop animation and set the rotation Angle. if set, Will not support drag.
- (void)dropAnimatedWithRotateAngle:(CGFloat)angle;

/// Block gets called when mask touched.
@property (nonatomic, copy) void (^maskTouched)(PZPopUpController *popupController);

/// - Should implement this block before the presenting. 应在present前实现的block ☟
/// Block gets called when contentView will present.
@property (nonatomic, copy) void (^willPresent)(PZPopUpController *popupController);

/// Block gets called when contentView did present.
@property (nonatomic, copy) void (^didPresent)(PZPopUpController *popupController);

/// Block gets called when contentView will dismiss.
@property (nonatomic, copy) void (^willDismiss)(PZPopUpController *popupController);

/// Block gets called when contentView did dismiss.
@property (nonatomic, copy) void (^didDismiss)(PZPopUpController *popupController);



@property (nonatomic, assign)BOOL isNotResponseTap;


/**
 present your content view.
 @param contentView This is the view that you want to appear in popup. / 弹出自定义的contentView
 @param duration Popup animation time. / 弹出动画时长
 @param isSpringAnimated if YES, Will use a spring animation. / 是否使用弹性动画
 @param sView  Displayed on the sView. if nil, Displayed on the window. / 显示在sView上
 @param displayTime The view will disappear after `displayTime` seconds. / 视图将在displayTime后消失
 */
- (void)presentContentView:(nullable UIView *)contentView
                  duration:(NSTimeInterval)duration
            springAnimated:(BOOL)isSpringAnimated
                    inView:(nullable UIView *)sView
               displayTime:(NSTimeInterval)displayTime;

- (void)presentContentView:(nullable UIView *)contentView
                  duration:(NSTimeInterval)duration
            springAnimated:(BOOL)isSpringAnimated
                    inView:(nullable UIView *)sView;

- (void)presentContentView:(nullable UIView *)contentView
                  duration:(NSTimeInterval)duration
            springAnimated:(BOOL)isSpringAnimated;

- (void)presentContentView:(nullable UIView *)contentView displayTime:(NSTimeInterval)displayTime;;

- (void)presentContentView:(nullable UIView *)contentView; // duration is 0.25 / springAnimated is NO / show in window

/// dismiss your content view.
- (void)dismissWithDuration:(NSTimeInterval)duration springAnimated:(BOOL)isSpringAnimated;

- (void)dismiss; // Will use the present parameter values.

@end

@protocol PZPopupControllerDelegate <NSObject>
@optional
// - The Delegate method, block is preferred.
- (void)popupControllerWillPresent:(nonnull PZPopUpController *)popupController;
- (void)popupControllerDidPresent:(nonnull PZPopUpController *)popupController;
- (void)popupControllerWillDismiss:(nonnull PZPopUpController *)popupController;
- (void)popupControllerDidDismiss:(nonnull PZPopUpController *)popupController;

@end

@interface UIViewController (PZPopUpController)

@property (nonatomic, strong) PZPopUpController *pz_popupController; // Suggested that direct use of pz_popupController.

@end


NS_ASSUME_NONNULL_END
